<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="utf-8"/>
    <title>首页 | 及第竞赛网</title>
    <link rel="stylesheet" href="../css/first.css"/>
    <link rel="stylesheet" href="../css/font-awesome.min.css">

</head>

<body>
<div class="container" id="home">
    <header class="header">
        <div class="brand">
            <div class="brand-icon">
                <a href="home.html">
                    <span>及第</span>竞赛网
                </a>
            </div>
        </div>
        <nav class="nav">
            <div class="nav-menu">
                <ul>
                    <li class="nav-btn">
                        <a href="home.html">首页</a>
                    </li>
                    <li class="nav-btn">
                        <a href="noticeOfContest.html">比赛公告</a>
                    </li>
                    <li class="nav-btn">
                        <a href="informationOfContest.html">比赛信息</a>
                    </li>
                    <li class="nav-btn">
                        <a href="newsOfContest.html">比赛资讯</a>
                    </li>
                    <!--<li class="nav-btn">-->
                        <!--<a href="">报名</a>-->
                    <!--</li>-->
                </ul>
            </div>
        </nav>
    </header>
    <!--比赛资讯start-->
    <div class="banner">
        <div class="banner-img">

            <a href="javascript:void(0)" @click="getOneNewsCookie(getOneNews.inId)">
                <img v-bind:src="getImgUrl(getOneNews.route)" alt="contest" style="width: 100%; height: 100%"/>
            </a>
        </div>
        <div class="banner-switch-left"><span><i class="fa fa-chevron-left"></i></span></div>
        <div class="banner-switch-right"><span><i class="fa fa-chevron-right"></i></span></div>
    </div>
    <section class="content">
        <section class="section">
            <div class="section-header">
                <div class="section-title">比赛资讯</div>
                <div class="section-more"><a href="newsOfContest.html">更多>></a></div>
            </div>
            <div class="section-body">
                <div class="section-list-img">
                    <ul >
                        <li v-for='MatchNews in MatchNewsList'>
                            <a href="javascript:void(0)" @click="getOneNewsCookie(MatchNews.inId)">
                                <img v-bind:src="getImgUrl(MatchNews.route)" alt="contest"/>
                                <span>{{MatchNews.title}}</span>
                            </a>
                        </li>
                    </ul>
                </div>
            </div>
        </section>
        <!--比赛资讯end-->
        <!--比赛信息start-->
        <div class="section-group">
            <section class="section">
                <div class="section-header">
                    <div class="section-title">比赛信息</div>
                    <div class="section-more"><a href="informationOfContest.html">更多>></a></div>
                </div>
                <div class="section-body">
                    <div class="section-list-text">
                        <ul v-for='match in matchLists'>
                            <li>
                                <a href="javascript:void(0)" @click="getOnematchCookie(match.deId)">
                                    <span class="section-list-content">
                                        {{match.title}}
                                    </span>
                                    <span class="section-list-time">{{match.releaseTime}}</span>
                                </a>
                            </li>
                        </ul>
                    </div>
                </div>
            </section>
            <!--比赛信息end-->
            <!--比赛公告start-->
            <section class="section">
                <div class="section-header">
                    <div class="section-title">比赛公告</div>
                    <div class="section-more"><a href="noticeOfContest.html">更多>></a></div>
                </div>
                <div class="section-body">
                    <div class="section-list-text">
                        <ul v-for="Notice in NoticeLists ">
                            <li>
                                <a href="javascript:void(0)" @click="getOneNotailCookie(Notice.noId)">
                                    <span class="section-list-content"> {{Notice.title}}</span>
                                    <span class="section-list-time">{{Notice.addtime}}</span>
                                </a>
                            </li>
                        </ul>
                    </div>
                </div>
            </section>
        </div>

    </section>
    <!--比赛公告end-->
</div>
<footer class="footer">
    <p>Copyright © 2018-2019 JIDI All rights reserved.</p>
</footer>

<script type="text/javascript" src="../js/vue.min.js"></script>
<script type="text/javascript" src="../js/axios.min.js"></script>
<script type="text/javascript" src="../js/cookieUtil.js"></script>

<script type="text/javascript">
    var url1 = "http://donting.free.idcfengye.com";
    var cp = new Vue({

        el: '#home',
        data: {

            NoticeLists: [], //所有公告信息
            MatchNewsList: [], //所有比赛资讯信息
            MatchNewsOne: {}, //一条资讯
            matchLists: [], //所有比赛信息
            getOneNews:{},  //得到一条资讯


        },
        methods: {
            getImgUrl:function(route){
                return url1+'/getImg?route='+route;
            },

            //						获取所有公告
            getAllNotice: function () {
                axios.defaults.withCredentials = true;
                axios.get(url1 + '/notice/findAllPage', {
                    params: {
                        page: '1',
                    }
                }).then(function (response) {
                    var rs = response.data;
                    if (rs.code == 200) {

                        cp.NoticeLists = rs.data;
                        console.log("获取公告成功");

                    } else {
                        console.log("获取公告失败");
                    }

                }).catch(function (error) {
                    console.log("获取公告连接超时！");
                });

            },

            //						获取所有比赛资讯
            getAllMatchNews: function () {
                axios.defaults.withCredentials = true;
                axios.get(url1 + '/information/findAllPage', {
                    params: {
                        page: '1',
                    }
                }).then(function (response) {
                    var rs = response.data;

                    if (rs.code == 200) {

                        cp.MatchNewsList = rs.data;
                        cp.getOneNews = rs.data[0];
                        console.log(cp.getOneNews+"getOneNews");

                        console.log("获取比赛资讯成功");
                    } else {
                        console.log("获取比赛资讯失败");
                    }

                }).catch(function (error) {
                    console.log("获取比赛资讯连接超时！");
                });
            },

            // 获取所有比赛信息
            getAllMatch: function () {
                axios.defaults.withCredentials = true;
                axios.get(url1 + '/details/findAllPage', {
                    params: {
                        page: '1'
                    }
                }).then(function (response) {
                    var rs = response.data;
                    cp.matchLists = rs.data;
                }).catch(function (error) {
                    alert("all连接超时！");
                });
          },

            //得到cookie
            getOneNewsCookie: function (id) {
                console.log("xxxcookie" + id);
                setCookie('inId', id, 1);
                document.location = "detailNews.html";
            },

            getOneNotailCookie: function (id) {
                console.log("xxxcookie" + id);
                setCookie('noId', id, 1);
                document.location = "detailNotice.html";

            },
            getOnematchCookie: function (id) {
                console.log("xxxcookie" + id);
                setCookie('deId', id, 1);
                document.location = "detailInformation.html";

            },
            //得到cookie End


        },
        mounted() {
            this.getAllMatchNews();
            this.getAllNotice();
            // this.getMatchNews();
            this.getAllMatch();
        }

    })
</script>

</body>

</html>